04. Debugging in ROS - Transform Frames
Debugging with Transform Frames
While developing your robot’s URDF file, you created several links and joints. Each link had its own coordinate frame, along with additional coordinate frames for the world (map) and the odometry frames.
The tf library helps keep track of all these different coordinate frames over time, and defines their relation with one another.
The library allows you to debug your coordinate frames (or the tf tree) in several ways. view_frames
will create a graphical representation of that tree, providing you with a broad view of how different frames (or links) in your setup connect to each other.
$ rosrun tf view_frames
The above will create a PDF file that will depict your tf tree as shown below.
Here is an example of a tf tree for a sample robot for this project:
Creating and reviewing the tf-tree is a great way to make sure that all of the links are in proper order. If, for instance, you saw that your laser sensor frame is connected to your right wheel’s coordinate frame, it would require you to take a step back and determine why it is not attached to the chassis.
You can also plot the different frames in RViz and visually inspect them there.
The tf
library also allows you to dynamically collect and display information between two transforms using tf_monitor
. This is great to make sure that two frames are associated in the expected way.
$ rosrun tf tf_monitor frame_1 frame_2
With these simple tools you can rapidly and visually diagnose any tf issues.
Sometimes those basic tests may not be enough. Here is a great tutorial if you find yourself in a more complicated tf problem. Though note that using these tools should not be necessary for this project, as the transforms are relatively simple compared to that of a robotic hand.
Another debugging tool under the tf
library that is useful for debugging your setup is roswtf
. Let’s check it out next!